/*
 * Created on 2005-3-26
 *
 */
package com.hd123.rumba.request;

import java.io.IOException;

import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.AxisHttpSession;
import org.apache.log4j.Logger;

/**
 * @author caili
 */
public class AxisActionAcl extends BasicHandler {
  public void invoke(MessageContext msgContext) throws AxisFault {
    Logger logger = Logger.getLogger(this.getClass());
    logger.debug(msgContext.getOperation().getName());
    AxisHttpSession as = (AxisHttpSession)msgContext.getSession();
    try {
      Dictionary dd = new Dictionary(as.getRep());
      if (dd.getSessionValue("_lasttime") == null)
        dd.putSessionValue("_lasttime", new java.util.Date());
      logger.debug(dd.printAll());
    } catch (IOException e) {
      throw AxisFault.makeFault(e);
    }

    //super.doPost(req, res);
  }

//  protected void sendMessage(HttpServletRequest req, HttpServletResponse res, String msg)
//      throws ServletException, IOException {
//    MessageContext msgContext = new MessageContext(getEngine());
//    Message responseMsg = msgContext.getResponseMessage();
//    if (responseMsg == null) {
//      responseMsg = new Message(new AxisFault(msg));
//      ((org.apache.axis.SOAPPart) responseMsg.getSOAPPart()).getMessage()
//          .setMessageContext(msgContext);
//      if (responseMsg != null) {
//        // Transfer MIME headers to HTTP headers for response message.
//        MimeHeaders responseMimeHeaders = responseMsg.getMimeHeaders();
//        for (Iterator i = responseMimeHeaders.getAllHeaders(); i.hasNext();) {
//          MimeHeader responseMimeHeader = (MimeHeader) i.next();
//          res.addHeader(responseMimeHeader.getName(), responseMimeHeader
//              .getValue());
//        }
//        // synchronize the character encoding of request and response
//        String responseEncoding = (String) msgContext
//            .getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
//        if (responseEncoding != null) {
//          try {
//            responseMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING,
//                responseEncoding);
//          } catch (SOAPException e) {
//          }
//        }
//        //determine content type from message response
//        String contentType = responseMsg.getContentType(msgContext
//            .getSOAPConstants());
//        res.setContentType(contentType);
//        try {
//          responseMsg.writeTo(res.getOutputStream());
//        } catch (SOAPException e) {
//          logException(e);
//        }
//        if (!res.isCommitted()) {
//          res.flushBuffer(); // Force it right now.
//        }
//      } else {
//        // No content, so just indicate accepted
//        res.setStatus(202);
//      }
//    }
//  }
//
//  protected String getSoapAction(HttpServletRequest req) throws AxisFault {
//    String soapAction = req.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
//    // the SOAP 1.1 spec & WS-I 1.0 says:
//    // soapaction = "SOAPAction" ":" [ <"> URI-reference <"> ]
//    // some implementations leave off the quotes
//    // we strip them if they are present
//    if (soapAction.startsWith("\"") && soapAction.endsWith("\"")
//        && soapAction.length() >= 2) {
//      int end = soapAction.length() - 1;
//      soapAction = soapAction.substring(1, end);
//    }
//
//    if (soapAction.length() == 0) {
//      soapAction = req.getContextPath(); // Is this right?
//
//    }
//    return soapAction;
//  }

}
